#@front_layout()
	
#define css()
	
#end

#define main()
	#--
	<input class="file" type="file" id="fafafa" name="fileupload"  multiple="multiple" onchange="uploadFile()"/>
	<div id="urls"></div>
	--#
#end

#define js()
<script>
	function uploadFile() {
		var file_obj = document.getElementById('fafafa').files;
	
	    var fd = new FormData();
	    for(var i = 0; i < file_obj.length; i++) {
		    fd.append('upfile', file_obj[i]);
	    }
	
	    $.ajax({
	        url: ctx + '/file/upload',
	        type:'POST',
	        data:fd,
	        processData:false,  //tell jQuery not to process the data
	        contentType: false,  //tell jQuery not to set contentType
	        dataType: 'json',
	        //这儿的三个参数其实就是XMLHttpRequest里面带的信息。
	        success:function (data) {
	        	for(var i = 0; i < data.length; i++) {
	        		$("#urls").append("<a href=" + data[i] + ">下载</a>");
	        	}
	        }
	    })
	}
</script>
#end